import socketserver

from html_handler import MyHandler
from question_parser import parse_txt
from question_of_fill_parser import parse_ipynb

PORT = 8000


if __name__ == "__main__":
    questionFilesOfFill = []
    parse_ipynb(
        r"D:\UserProfile\Desktop\人工智能训练师\考试相关-上机实操\代码相关-练习理解",
        questionFilesOfFill,
    )
    parse_ipynb(
        r"D:\UserProfile\Desktop\人工智能训练师\考试相关-上机实操\文字相关-死记硬背",
        questionFilesOfFill,
    )
    #纯字符串排序
    questionFilesOfFill.sort()

    demo_path = r"D:\UserProfile\Desktop\人工智能训练师\人工智能训练师三级（实操题和指导手册）2025\考试平台模拟界面";

    questions = parse_txt(r"人工智能训练师 理论 最终.chrome.pdf2txt.txt")

    def handler(*args):
        MyHandler(*args, questions=questions, questionFilesOfFill=questionFilesOfFill, demo_path = demo_path)

    with socketserver.TCPServer(("", PORT), handler) as httpd:
        print(f"访问 http://localhost:{PORT} 查看题目列表")
        httpd.serve_forever()
